<?php

require_once('HTML/reCAPTCHA/recaptchalib.php');
require_once('HTML/QuickForm/Rule.php');

/**
* ReCaptcha validation rule
* @version     1.0
*/
class ReCaptcha_Rule extends HTML_QuickForm_Rule
{
    function validate($value, $form)
    {
	$privatekey = '6LflQ-4SAAAAAN2fvrP6KrjoNfZiNrnUOHQOiwcX';
	$challenge = $form->getSubmitValue('recaptcha_challenge_field');
	$response = $form->getSubmitValue('recaptcha_response_field');
	$ip = $_SERVER["REMOTE_ADDR"];
	$resp = recaptcha_check_answer($privatekey, $ip, $challenge, $response);
	return $resp->is_valid;
    } // end func validate
} 
?>
